| Conditions | 1 | 
| Paths | 8 | 
| Total Lines | 42 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| Bugs | 0 | Features | 0 | 
| 1 | /* globals numberformat */ | ||
| 16 |     function(prettyNumber, $sce, data, state) { | ||
| 17 | /* Return the HTML representation of an element, or the element itself | ||
| 18 | if it doesn't have one */ | ||
| 19 |       this.getHTML = function(resource) { | ||
| 20 | let html = data.html[resource]; | ||
| 21 |         if (typeof html === 'undefined' && data.resources[resource]) { | ||
| 22 | html = data.resources[resource].html; | ||
| 23 | } | ||
| 24 |         if (typeof html === 'undefined') { | ||
| 25 | return resource; | ||
| 26 | } | ||
| 27 | return html; | ||
| 28 | }; | ||
| 29 | |||
| 30 |       this.prettifyNumber = function(number) { | ||
| 31 |         if (typeof number === 'undefined' || number === null) { | ||
| 32 | return null; | ||
| 33 | } | ||
| 34 |         if (number === '') { | ||
| 35 | return ''; | ||
| 36 | } | ||
| 37 |         if (number === Infinity) { | ||
| 38 | return '∞'; | ||
| 39 | } | ||
| 40 |         if (number === 0) { | ||
| 41 | return '0'; | ||
| 42 | } | ||
| 43 | return numberformat.format(number, state.player.numberformat); | ||
| 44 | }; | ||
| 45 | |||
| 46 |       this.addResource = function(resource, key, quantity){ | ||
| 47 | resource.number += quantity; | ||
| 48 |         if (quantity > 0 && !resource.unlocked) { | ||
| 49 | resource.unlocked = true; | ||
| 50 | state.addNew(key); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 |       this.trustHTML = function(html) { | ||
| 55 | return $sce.trustAsHtml(html); | ||
| 56 | }; | ||
| 57 | } | ||
| 58 | ]); | ||
| 59 |